<?php

class Admin_Model_Page extends Zend_Db_Table_Abstract
{
    protected $_name = 'core_pages';
    
    /**
     * 页面列表
     *
     * @param array $filter
     * @param string $sort
     * @return Zend_Paginator_Adapter_DbTableSelect
     */
    public function listPages ($filter = array(), $sort = null)
    {
        $select = $this->select();
        $select->setIntegrityCheck(false);
        $select->from($this->_name, '*');
        $msModelUser = new Ms_Model_User();
        $userTable = $msModelUser->getTableName();
        $select->join($userTable,"{$this->_name}.uid={$userTable}.id ",'username');
        
        if (count($filter) > 0){
            foreach($filter as $key=>$value){
                $select->where($key.' = ?', $value);
            }
        }
        if ($sort != null) {
            $select->order($sort.' DESC');
        }
        else{
            $select->order('updatetime DESC');
        }
        $adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
        return $adapter;
    }

}